const _function = require("../../utils/functionData.js")
Page({
  data: {
    lectureList: [
      // {
      //   id: 1,
      //   title: '前端开发趋势',
      //   time: '2023-10-15 14:00',
      //   status: '可报名',
      //   detail: '本次讲座将介绍前端开发的最新趋势...'
      // },
      // 更多讲座...
    ],
    lectureList1: []
  },
  onLoad() {
    this.getLectureList()
  },

  getLectureList(e) {
    console.log('选择时间', getApp().globalData.userInfo);
    const param = {
      studentId: getApp().globalData.userInfo.userId
    }
    _function.getLectureList(param, this.getLectureListBack, this)
  },
  getLectureListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      console.log('视频列表', dataAll);
      this.setData({
        lectureList: dataAll.rows
      })
      wx.showToast({
        title: dataAll.msg,
        icon: 'none', // 不显示图标
        duration: 1500, // 提示的延迟时间，单位毫秒，默认为 1500
        mask: true, // 是否显示透明蒙层，防止触摸穿透，默认为 `false`
        success: () => {
          // console.log('登录失败提示已显示');
        }
      });
    }
  },


  handleEnroll(event) {
    const lectureId = event.currentTarget.dataset.id;
    // 在这里实现报名逻辑，例如提交报名请求
    console.log(`报名讲座：${lectureId}`);
  },
  viewLectureDetail: function (event) {
    const lectureId = event.currentTarget.dataset.id;
    const status = event.currentTarget.dataset.status;
    wx.navigateTo({
      url: `/pages/lectureDetail/index?id=${lectureId}&status=${status}`
    });
  }
});